// /* Define to prevent recursive inclusion -------------------------------------*/
// #ifndef __imu_H__
// #define __imu_H__

// #ifdef __cplusplus
// extern "C" {
// #endif

// /* Includes ------------------------------------------------------------------*/
// #include "main.h"

// /* USER CODE BEGIN Includes */

// /* USER CODE END Includes */

// //extern UART_HandleTypeDef huart1;
// //extern UART_HandleTypeDef huart2;

// /* USER CODE BEGIN Private defines */

// /* USER CODE END Private defines */
// #define FRAME_HEAD 0xfc
// #define FRAME_END 0xfd
// #define TYPE_IMU 0x40
// #define TYPE_AHRS 0x41
// #define TYPE_INSGPS 0x42
// #define TYPE_GROUND 0xf0
// #define IMU_LEN  0x38   //56+8  8组数据
// #define AHRS_LEN 0x30   //48+8  7组数据
// #define INSGPS_LEN 0x42 //72+8  10组数据

// #define IMU_RS 64
// #define AHRS_RS 56

// typedef struct IMUData_Packet_t{
// 		float gyroscope_x;          //unit: rad/s
// 		float gyroscope_y;          //unit: rad/s
// 		float gyroscope_z;          //unit: rad/s
// 		float accelerometer_x;      //m/s^2
// 		float accelerometer_y;      //m/s^2
// 		float accelerometer_z;      //m/s^2
// 		float magnetometer_x;       //mG
// 		float magnetometer_y;       //mG
// 		float magnetometer_z;       //mG
// 		float imu_temperature;      //C
// 		float Pressure;             //Pa
// 		float pressure_temperature; //C
// 		uint32_t Timestamp;          //us
// } IMUData_Packet_t;

// typedef struct AHRSData_Packet_t
// {
// 	float RollSpeed;   //unit: rad/s
// 	float PitchSpeed;  //unit: rad/s
// 	float HeadingSpeed;//unit: rad/s
// 	float Roll;        //unit: rad
// 	float Pitch;       //unit: rad
// 	float Heading;     //unit: rad
// 	float Qw;//w          //Quaternion
// 	float Qx;//x
// 	float Qy;//y
// 	float Qz;//z
// 	uint32_t Timestamp; //unit: us
// }AHRSData_Packet_t;

// extern char IMU_RxBuff[256];
// //extern uint16_t IMU_Rx_Cnt;
// extern AHRSData_Packet_t AHRSData_Packet;
// //extern uint16_t IMU_Rec_OK;
// //void MX_USART1_UART_Init(void);
// //void MX_USART2_UART_Init(void);

// /* USER CODE BEGIN Prototypes */
// //void imu_init(UART_HandleTypeDef *huart,char * defaultsign);
// void imu_exe();
// //void Uart_Printf(char *fmt,...);
// /* USER CODE END Prototypes */

// #ifdef __cplusplus
// }
// #endif

// #endif /* __imu_H__ */

// /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/


#ifndef IMU_H
#define IMU_H

#define FRAME_HEADER      0X7B //Frame_header //֡ͷ
#define FRAME_TAIL        0X7D //Frame_tail   //֡β
#define SEND_DATA_SIZE    24
#define RECEIVE_DATA_SIZE 11
#define IMU_RS 64
#define AHRS_RS 56
#define INSGPS_RS 80

#define FRAME_HEAD 0xfc
#define FRAME_END 0xfd
#define TYPE_IMU 0x40
#define TYPE_AHRS 0x41
#define TYPE_INSGPS 0x42
#define TYPE_GROUND 0xf0
#define IMU_LEN  0x38   //56+8  8组数据
#define AHRS_LEN 0x30   //48+8  7组数据
#define INSGPS_LEN 0x42 //72+8  10组数据
#define IMU_CAN 9
#define AHRS_CAN 8
#define INSGPS_CAN 11
// //RS-485
// #define RS485_RX_DE		PAout(11)	//485模式控制.0,接收;1,发送.
// #define RS485_RX_RE		PAout(12)	//485模式控制.0,接收;1,发送.

extern uint8_t ttl_receive;


typedef struct IMUData_Packet_t{
		float gyroscope_x;          //unit: rad/s
		float gyroscope_y;          //unit: rad/s
		float gyroscope_z;          //unit: rad/s
		float accelerometer_x;      //m/s^2
		float accelerometer_y;      //m/s^2
		float accelerometer_z;      //m/s^2
		float magnetometer_x;       //mG
		float magnetometer_y;       //mG
		float magnetometer_z;       //mG
		float imu_temperature;      //C
		float Pressure;             //Pa
		float pressure_temperature; //C
		uint32_t Timestamp;          //us
} IMUData_Packet_t;

typedef struct AHRSData_Packet_t
{
	float RollSpeed;   //unit: rad/s
	float PitchSpeed;  //unit: rad/s
	float HeadingSpeed;//unit: rad/s
	float Roll;        //unit: rad
	float Pitch;       //unit: rad
	float Heading;     //unit: rad
	float Qw;//w          //Quaternion
	float Qx;//x
	float Qy;//y
	float Qz;//z
	uint32_t Timestamp; //unit: us
}AHRSData_Packet_t;



void imu_exe();
uint8_t TTL_Hex2Dec(void);  

float DATA_Trans(uint8_t Data_1,uint8_t Data_2,uint8_t Data_3,uint8_t Data_4);
long long timestamp(uint8_t Data_1,uint8_t Data_2,uint8_t Data_3,uint8_t Data_4);
void PrintAHRSData(void);
void PrintIMUData(void);

#endif // IMU_H